<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>fft2</title>
  </head>
  <body bgcolor="#FFFFFF">
    <center>Scilab Function</center>
    <div align="right">Last update : 09/02/2006</div>
    <p>
      <b>fft2</b> - two-dimension fast Fourier
  transform</p>
    <h3>
      <font color="blue">Calling Sequence</font>
    </h3>
    <dl>
      <dd>
        <tt>y=fft2(x)</tt>
      </dd>
      <dd>
        <tt>y=fft2(x,n,m)</tt>
      </dd>
    </dl>
    <h3>
      <font color="blue">Parameters</font>
    </h3>
    <ul>
      <li>
        <tt>
          <b>x</b>
        </tt>: a vector/matrix/array (Real or Complex)</li>
      <li>
        <tt>
          <b>y</b>
        </tt>: a vector/matrix/array (Real or Complex)</li>
      <li>
        <tt>
          <b>m</b>
        </tt>: integer, number of rows.</li>
      <li>
        <tt>
          <b>n</b>
        </tt>: integer, number of columns.</li>
    </ul>
    <h3>
      <font color="blue">Description</font>
    </h3>
    <pre>This functions performs the two-dimension discrete Fourier
    transform.</pre>
    <p>
      <tt>
        <b>y=fft2(x)</b>
      </tt>: y and x have the same size</p>
    <p>
      <tt>
        <b>y=fft2(x,m,n):</b>
      </tt> If <tt>
        <b>m</b>
      </tt> (respectively
    <tt>
        <b>n</b>
      </tt>) is less than the rows number (respectively columns) of
    <tt>
        <b>x</b>
      </tt> then the <tt>
        <b>x</b>
      </tt> rows number (resp. columns) is
    truncated, else if m (resp. <tt>
        <b>n</b>
      </tt>) is more than the rows number
    (resp. columns) of <tt>
        <b>x</b>
      </tt> then <tt>
        <b>x</b>
      </tt> rows are completed
    by zero (resp. columns) .</p>
    <p>if <tt>
        <b>x</b>
      </tt> is a matrix then <tt>
        <b>y</b>
      </tt> is a matrix, if
    <tt>
        <b>x</b>
      </tt> is a hypermatrix then <tt>
        <b>y</b>
      </tt> is a hypermatrix, with
    the size of the first dimension of <tt>
        <b>y</b>
      </tt> is equal to
    <tt>
        <b>m</b>
      </tt>, the size of the second dimension of <tt>
        <b>y</b>
      </tt> is
    equal to <tt>
        <b>n</b>
      </tt>, the size of the ith dimension of <tt>
        <b>y</b>
      </tt>
    (for i&gt;2, case hypermatrix) equal to the size of the ith dimension of
    <tt>
        <b>x</b>
      </tt>. (i.e size(y,1)=m, size(y,2)=n and size(y,i)=size(x,i) for
    i&gt;2)</p>
    <h3>
      <font color="blue">Examples</font>
    </h3>
    <pre>
//Comparison with explicit formula
a=[1 2 3 ;4 5 6 ;7 8 9 ;10 11 12]  
m=size(a,1)
n=size(a,2)
// fourier transform along the rows
for i=1:n
a1(:,i)=exp(-2*%i*%pi*(0:m-1)'.*.(0:m-1)/m)*a(:,i) 
end
// fourier transform along the columns
for j=1:m
a2temp=exp(-2*%i*%pi*(0:n-1)'.*.(0:n-1)/n)*(a1(j,:)).' 
a2(j,:)=a2temp.'
end
norm(a2-fft2(a))


 
  </pre>
    <h3>
      <font color="blue">See Also</font>
    </h3>
    <p>
      <a href="fft.htm">
        <tt>
          <b>fft</b>
        </tt>
      </a>,&nbsp;&nbsp;</p>
  </body>
</html>
